<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html lang="zh-cn" style="height: 100%">
<base href="<%=basePath%>">
<head>
	<meta charset="UTF-8">
	<meta name="format-detection" content="telephone=no" />
	<meta name="viewport"content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>手机群录</title>
	<link rel="stylesheet" href="css/base.css">
	<style type="text/css">
		.card_wrap{
			padding: 5px 15px 5px;
		}
	</style>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/base.js"></script>
	<script type="text/javascript" src="js/common.js"></script>
	<script type="text/javascript" src="js/handle.js"></script>
	<script type="text/javascript" src="js/sort.js"></script>
	<script type="text/javascript">
		var fromPage = "${fromPage}"; // 记录上一个页面
//        var r ={"code":"00","msg":"成功","data":[{"createTime":"2017-05-24 14:41","name":"华南理工大学校友 ","id":"09a4702f-ebad-4746-bafc-5a8eb38afc6d","proName":"团员","type":1,"depName":"14软件工程1班","mark":"gcu-xiaoyou"},{"createTime":"2017-05-25 00:03","name":"华广14软件1班","id":"e8668bff-6f46-4926-ae5a-560c3c882316","proName":"学生","typId":0,"depName":"学生","mark":"gcu-14soft-one"},{"createTime":"2017-05-25 00:04","name":"华广14软件1班班团干","id":"96ef6b26-9f3e-46b6-81ac-3ddc7bdc9a2b","proName":"班长","typId":0,"depName":"学生","mark":"gcu-14soft-one-leader"},{"createTime":"2017-09-04 19:36","name":"华软集团","id":"4cdb0563-0d19-4131-aa69-76a19d69cfec","proName":"普通员工","typId":0,"depName":"研发二部","mark":"hgits-soft-one"},{"createTime":"2017-05-24 14:41","name":"华南理工大学校友","id":"09a4702f-ebad-4746-bafc-5a8eb38afc6d","proName":"团员","typId":1,"depName":"14软件工程1班","mark":"gcu-xiaoyou"},{"createTime":"2017-05-25 00:03","name":"华广14软件1班","id":"e8668bff-6f46-4926-ae5a-560c3c882316","proName":"学生","typId":0,"depName":"学生","mark":"gcu-14soft-one"},{"createTime":"2017-05-25 00:04","name":"华广14软件1班班团干","id":"96ef6b26-9f3e-46b6-81ac-3ddc7bdc9a2b","proName":"班长","typId":0,"depName":"学生","mark":"gcu-14soft-one-leader"},{"createTime":"2017-09-04 19:36","name":"华软集团","id":"4cdb0563-0d19-4131-aa69-76a19d69cfec","proName":"普通员工","typId":0,"depName":"研发二部","mark":"hgits-soft-one"}]};
        var r = ${result};
		var list = []; // 卡片信息数组
		for (var i = 0; i < r.data.length; i++) {
			var obj = r.data[i];
			var name = obj.name;
			var typeName = "";
			var oid = obj.id;
			var type = obj.type;
			if(type == 2){
                typeName = "PUBLIC"
			}else if (type ==1) {
                typeName="PROTECTED"
			}else {
                typeName="PRIVATE";
			}
			list.push([name,type,typeName,"",oid]);
		};

		// 点击选中卡后返回原来页面
		function goBack(ele) {
            var oid = $(ele).attr("data-cardNo");
            window.location.href = "wxmp/group/toMobile?oid="+oid+"&fromPage="+fromPage;
		}

		// 根据卡列表的长度加载页面
		function loadCard(list) {
			console.log(list);
			if(!list) {
				return;
			}

			var clr;
			if (list.length == 0) {
				$(".nocard").removeClass('none');
				$(".wrap").addClass('none');
			}else {
				for (var i = 0; i < list.length; i++) {
                    if (list[i][1] == 0) {
                        clr = "blue";
                    } else if (list[i][1] == 1){
                        clr = "ot";
                    }else {
                        clr = "red"
                    }
					var limitdate =  "<img src='img/call3.png'>";
					var typeName = ""+list[i][2]; // 每4位用空格分隔
					var innerText = "<div style=' '" +
						"class='card_wrap card_wrap_"+ clr +"' data-cardNo='"
							+ list[i][4]
							+"' data-balance='"
							+ list[i][4]
							+"' data-vehiclePlate='"
							+list[i][0]
							+"' onclick='goBack(this)'>"
							+"<h3> <i class = 'icon_card '></i>"
							+ list[i][0]
							+"<span>"
							+"<i>"
							+ limitdate
							+"</i>"
							+"</span></h3>"
							"</div>";

					/*+"<h4>"
//							+ typeName
							+"</h4>"
							+ "<h5>"+createTime
							+"</h5>
					* */
					$(".card_list").append(innerText);
				};
				$(".card_wrap[data-cardno="+ "000000000" +"]").addClass('cardNoHasChosen'); // 突出显示已选中的卡片
				$(".nocard").addClass('none');
				$(".wrap").removeClass('none');
			}
		}

		$(function () {
			loadCard(list); // 绘制卡列表的dom
		})
	</script>
</head>
<body class="ed" style = "position:relative">
<div class="wrap ">
	<div class="card_list"></div>
</div>
<div class="mask_layer none" >
	<div class="unbind_box">
		<p class="unbindBtn" id="unbindCard">退出</p>
		<p class="cancelBtn">取消</p>

	</div>
</div>
<div class="nocard">
	<img src="img/nobindcard.png">
	<h3>你没有加入任何团队哦</h3>
	<p onclick="javascript:wx.closeWindow();">关闭</p>
</div>
<div class="toast toast_timeout" style="display:none">网络异常，请稍后重试！</div>
<div class="toast toast_error" style="display:none">信息输入有误</div>
<div class="loading" style="display:none">
	<img src="img/loading.gif"></div>
</body>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script type="text/javascript" src="js/weixin.js"></script>
<script type="text/javascript">
    getSignature([],function () {
        shareMobileGroup("${fromUser}");
    })
</script>
</html>